#nested json filter react js
Explore tagged Tumblr posts
Text
İç içe nesneler nasıl filtrelenir? ReactJS
örnek datamız
let reportData = [{ label:"Özel Raporlar", reports:[ { reportName:"Deneme Özel Rapor", description: "Özel raporu acıklaması", favorite:false }, { reportName:"Deneme Özel Rapor 2", description: "Özel raporu acıklaması", favorite:false }, ] }, { label:"Favoriler", reports:[ { reportName:" Zarf", description: "rapor acıklaması", favorite:true }, ] }]
const result = reportData .map(item => ({ ...item, reports: item.reports .filter(child => child.reportName.toLowerCase().includes(query.toLowerCase()) ) }))
.filter(item => item.reports.length > 0)
console.log("result",result)
2 notes
·
View notes